/**
*  
* @Function 数据采集Controller 
* @ProjectName credit-data-platform 
* @PackageName com.py.credit.controller    
* @FileName DataCollectionController.java    
* @Date 2018年6月22日下午12:04:47
* @Author Min DongXv
* @Copyright (c) 2018, 金电联行 All Rights Reserved.   
*   
*/
package com.py.credit.controller;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.py.credit.common.logs.ExceptionLogger;
import com.py.credit.common.rest.RestServiceResult;
import com.py.credit.entity.SysUser;
import com.py.credit.entity.common.OptionalColumn;
import com.py.credit.entity.enums.DataCollectionFieldsEnum;
import com.py.credit.service.DataCollectionService;
import com.py.credit.service.GetRoleService;
import com.py.credit.service.RemoteBaseService;
import com.py.credit.utils.DateUtil;
import com.py.credit.utils.ExcelUtil;
import com.py.framework.core.annotation.IgnoreAuthority;
import com.py.framework.core.common.Page;
import com.py.framework.core.helper.HttpServletHelper;

/**
 * 
 * @Function 数据采集Controller
 * @ClassName DataCollectionController
 * @Date 2018年6月22日 下午12:04:47
 * @Author Min DongXv
 * 
 */
@RestController
@RequestMapping(value = "/dataCollection")
public class DataCollectionController extends BaseController {

	@Autowired
	private DataCollectionService dataCollectionService;

	@Autowired
	private RemoteBaseService remoteBaseService;
	@Autowired
    private GetRoleService getRoleService;
	/**
	 * 获取初始化列
	 * 
	 * @return
	 */
	@RequestMapping(value = "/getOptionalColums.json")
	public RestServiceResult<List<OptionalColumn>> getOptionalColums() {
		return new RestServiceResult<List<OptionalColumn>>(DataCollectionFieldsEnum.getOptionalColumns());
	}

	@RequestMapping(value = "/getAdvancedConditionColumns.json")
	public RestServiceResult<List<OptionalColumn>> getAdvancedConditionColumns() {
		return new RestServiceResult<List<OptionalColumn>>(DataCollectionFieldsEnum.getAdvancedConditionColumns());
	}

	/**
	 * 
	 * @api {get} /dataCollection/getTime.json 获取期数信息
	 * @apiName getTime
	 * @apiVersion 0.0.1
	 * @apiGroup 数据采集
	 * @apiSuccess {String} code 状态码:1 成功 -1 失败
	 * @apiSuccess {String} msg 错误信息
	 * @apiSuccess {int} count 结果集数据量
	 * @apiSuccess {String} data 结果集
	 */
	@RequestMapping(value = "/getTime")
	public RestServiceResult<JSONObject> getTime() {
		JSONObject jb = new JSONObject();
		jb.put("number", new SimpleDateFormat("yyyyMM").format(new Date()));
		SimpleDateFormat df = new SimpleDateFormat(DateUtil.YYYY_MM_DD);
		Calendar c = Calendar.getInstance();
		c.setTime(new Date());
		int days = c.getActualMaximum(Calendar.DAY_OF_MONTH);
		jb.put("days", days - c.get(Calendar.DAY_OF_MONTH));
		c.set(Calendar.DAY_OF_MONTH, days);
		jb.put("endDate", df.format(c.getTime()));
		c.set(Calendar.DAY_OF_MONTH, 1);
		jb.put("startDate", df.format(c.getTime()));
		return new RestServiceResult<JSONObject>(jb);
	}

	/**
	 * 
	 * @api {get} /dataCollection/getResourceList.json 获取数据采集列表
	 * @apiName getResourceList
	 * @apiVersion 0.0.1
	 * @apiGroup 数据采集
	 * @apiParam {Page} page
	 * @apiParam {Integer} isFinish
	 * @apiParam {Integer} rootId
	 * @apiParam {String} condition
	 * @apiParamExample {json} 请求参数示例 {"isFinish":1,"rootId":100000}
	 * @apiSuccess {String} code 状态码:1 成功 -1 失败
	 * @apiSuccess {String} msg 错误信息
	 * @apiSuccess {int} count 结果集数据量
	 * @apiSuccess {String} data 结果集
	 * @apiSuccess {String} result
	 * @apiSuccessExample {json} 成功返回结果 {}
	 */
	@RequestMapping(value = "/getResourceList.json")
	public RestServiceResult<List<Map<String, Object>>> getResourceList(HttpServletRequest request, Page page,
			@RequestParam(value = "isFinish", defaultValue = "", required = true) Integer isFinish,
			@RequestParam(value = "rootId", defaultValue = "", required = true) Integer rootId,
			@RequestParam(value = "resourceName", defaultValue = "", required = true) String resourceName,
			@RequestParam(value = "updateFrequency", defaultValue = "", required = true) String updateFrequency,
			@RequestParam(value = "condition", defaultValue = "", required = true) String condition) {
		RestServiceResult<List<Map<String, Object>>> result = new RestServiceResult<>();
		String token = HttpServletHelper.getUserToken(request);
		// 获取当前用户信息
		RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(token);
		 String rolename="";
		SysUser userInfo = null;
		List<SysUser> userList = new ArrayList<SysUser>();
		if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
			userInfo = user.getData();
			if (null == userInfo || userInfo.getId() <= 0) {
				result.setCode(RestServiceResult.CODE_UNKNOW);
				result.setMsg("系统异常，请稍后再试！");
				ExceptionLogger.error("BatchLogController#exportBookcontentList", "未获取到当前用户信息！");
				return result;
			}
			rolename=userInfo.getRoleName();
			userList.add(userInfo);
		} else {
			result.setCode(user.getCode());
			result.setMsg(user.getMsg());
			return result;
		}
		Calendar c = Calendar.getInstance();
		int mon = c.get(Calendar.MONTH) + 1;
		try {
			List<String> showColumns = DataCollectionFieldsEnum.getDefaultShowColumnEN();
			List<Map<String, Object>> data = null;
			
				// 获取数据采集列表
				 data = dataCollectionService.getResourceListByConditionForPage(userInfo, isFinish,
						rootId, condition, page, showColumns, null,rolename);
			
			
			if (!CollectionUtils.isEmpty(data)) {
				Set<Integer> userIds = new HashSet<Integer>(data.size());
				for (Map<String, Object> m : data) {
					if (null != m) {
						if (m.containsKey("managerId") && null != m.get("managerId")) {
							userIds.add(Integer.parseInt(String.valueOf(m.get("managerId"))));
						}
						String frequency = String.valueOf(m.get("updateFrequency"));
						// 季度未完成的数据，非最后一个月改为进行中
						if ("Q".equals(frequency) && "0".equals(String.valueOf(m.get("isFinish")))) {
							if (mon % 3 > 0) {
								m.put("isFinish", "2");
							}
							// 年度未完成的数据，非最后一个月改为进行中
						} else if ("Y".equals(frequency) && "0".equals(String.valueOf(m.get("isFinish")))) {
							if (mon % 12 > 0) {
								m.put("isFinish", "2");
							}
						} else if (!"M".equals(frequency)) {
							m.put("isFinish", "3");
						}
					}
				}
				// 填充用户名称
				remoteBaseService.matchUserName(data, result, token, userIds, "managerId", "lastOperatorName");
			}
			result.setCount(page.getTotalCount());
			result.setData(data);
			return result;
		} catch (Exception e) {
			ExceptionLogger.error("BatchLogController#getResourceList", "获取数据采集资源异常！ERROR：" + e.getMessage(), e);
			result.setCode(RestServiceResult.CODE_UNKNOW);
			result.setMsg("获取数据采集资源异常！");
			return result;
		}
	}

	@RequestMapping(value = "/export")
	public RestServiceResult<List<Map<String, Object>>> exportData(
			@RequestParam(value = "isFinish", defaultValue = "", required = true) Integer isFinish,
			@RequestParam(value = "rootId", defaultValue = "", required = true) Integer rootId,
			@RequestParam(value = "resourceName", defaultValue = "", required = true) String resourceName,
			@RequestParam(value = "updateFrequency", defaultValue = "", required = true) String updateFrequency,
			@RequestParam(value = "condition", defaultValue = "", required = true) String condition,
			@RequestParam(value = "columnEN", defaultValue = "", required = true) String columnEN, Page page,
			HttpServletResponse response, HttpServletRequest request) {
		page.setLimit(1000);
		RestServiceResult<List<Map<String, Object>>> result = new RestServiceResult<>();
		String token = HttpServletHelper.getUserToken(request);
		// 获取当前用户信息
		RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(token);
		SysUser userInfo = null;
		List<SysUser> userList = new ArrayList<SysUser>();
		if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
			userInfo = user.getData();
			if (null == userInfo || userInfo.getId() <= 0) {
				result.setCode(RestServiceResult.CODE_UNKNOW);
				result.setMsg("系统异常，请稍后再试！");
				ExceptionLogger.error("BatchLogController#exportBookcontentList", "未获取到当前用户信息！");
				return result;
			}
			userList.add(userInfo);
		} else {
			result.setCode(user.getCode());
			result.setMsg(user.getMsg());
			return result;
		}
		Calendar c = Calendar.getInstance();
		int mon = c.get(Calendar.MONTH) + 1;
		try {
			List<String> showColumns = DataCollectionFieldsEnum.getDefaultShowColumnEN();
			// 获取数据采集列表
			List<Map<String, Object>> data = dataCollectionService.getResourceListByConditionForPage(userInfo, isFinish,
					rootId, condition, page, showColumns, null,null);
			if (!CollectionUtils.isEmpty(data)) {
				Set<Integer> userIds = new HashSet<Integer>(data.size());
				for (Map<String, Object> m : data) {
					if (null != m) {
						if (m.containsKey("managerId") && null != m.get("managerId")) {
							userIds.add(Integer.parseInt(String.valueOf(m.get("managerId"))));
						}
						String frequency = String.valueOf(m.get("updateFrequency"));
						// 季度未完成的数据，非最后一个月改为进行中
						if ("Q".equals(frequency) && "0".equals(String.valueOf(m.get("isFinish")))) {
							if (mon % 3 > 0) {
								m.put("isFinish", "2");
							}
							// 年度未完成的数据，非最后一个月改为进行中
						} else if ("Y".equals(frequency) && "0".equals(String.valueOf(m.get("isFinish")))) {
							if (mon % 12 > 0) {
								m.put("isFinish", "2");
							}
						} else if (!"M".equals(frequency)) {
							m.put("isFinish", "3");
						}
					}
				}
				// 填充用户名称
				remoteBaseService.matchUserName(data, result, token, userIds, "managerId", "lastOperatorName");
				ExcelUtil.downloadExcel(response, data, "数据采集", "数据采集", showColumns,
						DataCollectionFieldsEnum.getOptionalColumns());
			}
			return result;
		} catch (Exception e) {
			ExceptionLogger.error("BatchLogController#exportData", "数据采集导出异常！ERROR：" + e.getMessage(), e);
			result.setCode(RestServiceResult.CODE_UNKNOW);
			result.setMsg("数据采集导出异常！");
			return result;
		}
	}
	/**
	 * 获取每个部门采集数据量
	 * @return
	 */
	@IgnoreAuthority
	@RequestMapping("/getTcountGroup.json")
	public RestServiceResult<List<Map<String, Object>>> getTcountGroupByDept(){
		RestServiceResult<List<Map<String, Object>>> result = new RestServiceResult<>();
		try {
			List<Map<String, Object>> data = dataCollectionService.getTcountGroupByDept();
			result.setData(data);
		} catch (Exception e) {
			result.setMsg("获取数据异常");
		}
		
		return result;
	}



	/**
	 *
	 * @api {get} /dataCollection/getDoubleResourceList.json 获取数据采集列表
	 * @apiName getResourceList
	 * @apiVersion 0.0.1
	 * @apiGroup 数据采集
	 * @apiParam {Page} page
	 * @apiParam {Integer} isFinish
	 * @apiParam {Integer} rootId
	 * @apiParam {String} condition
	 * @apiParamExample {json} 请求参数示例 {"isFinish":1,"rootId":100000}
	 * @apiSuccess {String} code 状态码:1 成功 -1 失败
	 * @apiSuccess {String} msg 错误信息
	 * @apiSuccess {int} count 结果集数据量
	 * @apiSuccess {String} data 结果集
	 * @apiSuccess {String} result
	 * @apiSuccessExample {json} 成功返回结果 {}
	 */
	@RequestMapping(value = "/getDoubleResourceList.json")
	public RestServiceResult<List<Map<String, Object>>> getDoubleResourceList(HttpServletRequest request, Page page,
																		@RequestParam(value = "isFinish", defaultValue = "", required = true) Integer isFinish,
																		@RequestParam(value = "rootId", defaultValue = "", required = true) Integer rootId,
																		@RequestParam(value = "resourceName", defaultValue = "", required = true) String resourceName,
																		@RequestParam(value = "updateFrequency", defaultValue = "", required = true) String updateFrequency,
																		@RequestParam(value = "condition", defaultValue = "", required = true) String condition) {
		RestServiceResult<List<Map<String, Object>>> result = new RestServiceResult<>();
		String token = HttpServletHelper.getUserToken(request);
		// 获取当前用户信息
		RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(token);
		String rolename="";
		SysUser userInfo = null;
		List<SysUser> userList = new ArrayList<SysUser>();
		if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
			userInfo = user.getData();
			if (null == userInfo || userInfo.getId() <= 0) {
				result.setCode(RestServiceResult.CODE_UNKNOW);
				result.setMsg("系统异常，请稍后再试！");
				ExceptionLogger.error("BatchLogController#getDoubleResourceList", "未获取到当前用户信息！");
				return result;
			}
			rolename=userInfo.getRoleName();
			userList.add(userInfo);
		} else {
			result.setCode(user.getCode());
			result.setMsg(user.getMsg());
			return result;
		}
		Calendar c = Calendar.getInstance();
		int mon = c.get(Calendar.MONTH) + 1;
		try {
			List<String> showColumns = DataCollectionFieldsEnum.getDefaultShowColumnEN();
			List<Map<String, Object>> data = null;

			// 获取数据采集列表
			data = dataCollectionService.getDoubleResourceListByConditionForPage(userInfo, isFinish,
					rootId, condition, page, showColumns, null,rolename);


			if (!CollectionUtils.isEmpty(data)) {
				Set<Integer> userIds = new HashSet<Integer>(data.size());
				for (Map<String, Object> m : data) {
					if (null != m) {
						if (m.containsKey("managerId") && null != m.get("managerId")) {
							userIds.add(Integer.parseInt(String.valueOf(m.get("managerId"))));
						}
						String frequency = String.valueOf(m.get("updateFrequency"));
						// 季度未完成的数据，非最后一个月改为进行中
						if ("Q".equals(frequency) && "0".equals(String.valueOf(m.get("isFinish")))) {
							if (mon % 3 > 0) {
								m.put("isFinish", "2");
							}
							// 年度未完成的数据，非最后一个月改为进行中
						} else if ("Y".equals(frequency) && "0".equals(String.valueOf(m.get("isFinish")))) {
							if (mon % 12 > 0) {
								m.put("isFinish", "2");
							}
						} else if (!"M".equals(frequency)) {
							m.put("isFinish", "3");
						}
					}
				}
				// 填充用户名称
				remoteBaseService.matchUserName(data, result, token, userIds, "managerId", "lastOperatorName");
			}
			result.setCount(page.getTotalCount());
			result.setData(data);
			return result;
		} catch (Exception e) {
			ExceptionLogger.error("BatchLogController#getDoubleResourceList", "获取数据采集资源异常！ERROR：" + e.getMessage(), e);
			result.setCode(RestServiceResult.CODE_UNKNOW);
			result.setMsg("获取数据采集资源异常！");
			return result;
		}
	}


	/**
	 *
	 * @api {get} /dataCollection/getDoubleResourceList.json 获取数据采集列表
	 * @apiName getResourceList
	 * @apiVersion 0.0.1
	 * @apiGroup 数据采集
	 * @apiParam {Page} page
	 * @apiParam {Integer} isFinish
	 * @apiParam {Integer} rootId
	 * @apiParam {String} condition
	 * @apiParamExample {json} 请求参数示例 {"isFinish":1,"rootId":100000}
	 * @apiSuccess {String} code 状态码:1 成功 -1 失败
	 * @apiSuccess {String} msg 错误信息
	 * @apiSuccess {int} count 结果集数据量
	 * @apiSuccess {String} data 结果集
	 * @apiSuccess {String} result
	 * @apiSuccessExample {json} 成功返回结果 {}
	 */
	@RequestMapping(value = "/getDoubleFrResourceList.json")
	public RestServiceResult<List<Map<String, Object>>> getDoubleFrResourceList(HttpServletRequest request, Page page,
																			  @RequestParam(value = "isFinish", defaultValue = "", required = true) Integer isFinish,
																			  @RequestParam(value = "rootId", defaultValue = "", required = true) Integer rootId,
																			  @RequestParam(value = "resourceName", defaultValue = "", required = true) String resourceName,
																			  @RequestParam(value = "updateFrequency", defaultValue = "", required = true) String updateFrequency,
																			  @RequestParam(value = "condition", defaultValue = "", required = true) String condition) {
		RestServiceResult<List<Map<String, Object>>> result = new RestServiceResult<>();
		String token = HttpServletHelper.getUserToken(request);
		// 获取当前用户信息
		RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(token);
		String rolename="";
		SysUser userInfo = null;
		List<SysUser> userList = new ArrayList<SysUser>();
		if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
			userInfo = user.getData();
			if (null == userInfo || userInfo.getId() <= 0) {
				result.setCode(RestServiceResult.CODE_UNKNOW);
				result.setMsg("系统异常，请稍后再试！");
				ExceptionLogger.error("BatchLogController#getDoubleFrResourceList", "未获取到当前用户信息！");
				return result;
			}
			rolename=userInfo.getRoleName();
			userList.add(userInfo);
		} else {
			result.setCode(user.getCode());
			result.setMsg(user.getMsg());
			return result;
		}
		Calendar c = Calendar.getInstance();
		int mon = c.get(Calendar.MONTH) + 1;
		try {
			List<String> showColumns = DataCollectionFieldsEnum.getDefaultShowColumnEN();
			List<Map<String, Object>> data = null;

			// 获取数据采集列表
			data = dataCollectionService.getDoubleFrResourceListByConditionForPage(userInfo, isFinish,
					rootId, condition, page, showColumns, null,rolename);


			if (!CollectionUtils.isEmpty(data)) {
				Set<Integer> userIds = new HashSet<Integer>(data.size());
				for (Map<String, Object> m : data) {
					if (null != m) {
						if (m.containsKey("managerId") && null != m.get("managerId")) {
							userIds.add(Integer.parseInt(String.valueOf(m.get("managerId"))));
						}
						String frequency = String.valueOf(m.get("updateFrequency"));
						// 季度未完成的数据，非最后一个月改为进行中
						if ("Q".equals(frequency) && "0".equals(String.valueOf(m.get("isFinish")))) {
							if (mon % 3 > 0) {
								m.put("isFinish", "2");
							}
							// 年度未完成的数据，非最后一个月改为进行中
						} else if ("Y".equals(frequency) && "0".equals(String.valueOf(m.get("isFinish")))) {
							if (mon % 12 > 0) {
								m.put("isFinish", "2");
							}
						} else if (!"M".equals(frequency)) {
							m.put("isFinish", "3");
						}
					}
				}
				// 填充用户名称
				remoteBaseService.matchUserName(data, result, token, userIds, "managerId", "lastOperatorName");
			}
			result.setCount(page.getTotalCount());
			result.setData(data);
			return result;
		} catch (Exception e) {
			ExceptionLogger.error("BatchLogController#getDoubleFrResourceList", "获取数据采集资源异常！ERROR：" + e.getMessage(), e);
			result.setCode(RestServiceResult.CODE_UNKNOW);
			result.setMsg("获取数据采集资源异常！");
			return result;
		}
	}
	
	/**
	 *
	 * @api {get} /dataCollection/getTenResourceList.json 获取十公示数据采集列表
	 * @apiName getResourceList
	 * @apiVersion 0.0.1
	 * @apiGroup 数据采集
	 * @apiParam {Page} page
	 * @apiParam {Integer} isFinish
	 * @apiParam {Integer} rootId
	 * @apiParam {String} condition
	 * @apiParamExample {json} 请求参数示例 {"isFinish":1,"rootId":100000}
	 * @apiSuccess {String} code 状态码:1 成功 -1 失败
	 * @apiSuccess {String} msg 错误信息
	 * @apiSuccess {int} count 结果集数据量
	 * @apiSuccess {String} data 结果集
	 * @apiSuccess {String} result
	 * @apiSuccessExample {json} 成功返回结果 {}
	 */
	@RequestMapping(value = "/getTenResourceList.json")
	public RestServiceResult<List<Map<String, Object>>> getTenResourceList(HttpServletRequest request, Page page,
																		@RequestParam(value = "isFinish", defaultValue = "", required = true) Integer isFinish,
																		@RequestParam(value = "rootId", defaultValue = "", required = true) Integer rootId,
																		@RequestParam(value = "resourceName", defaultValue = "", required = true) String resourceName,
																		@RequestParam(value = "updateFrequency", defaultValue = "", required = true) String updateFrequency,
																		@RequestParam(value = "condition", defaultValue = "", required = true) String condition) {
		RestServiceResult<List<Map<String, Object>>> result = new RestServiceResult<>();
		String token = HttpServletHelper.getUserToken(request);
		// 获取当前用户信息
		RestServiceResult<SysUser> user = remoteBaseService.getCurrentUser(token);
		String rolename="";
		SysUser userInfo = null;
		List<SysUser> userList = new ArrayList<SysUser>();
		if (RestServiceResult.CODE_SUCCESS == user.getCode()) {
			userInfo = user.getData();
			if (null == userInfo || userInfo.getId() <= 0) {
				result.setCode(RestServiceResult.CODE_UNKNOW);
				result.setMsg("系统异常，请稍后再试！");
				ExceptionLogger.error("BatchLogController#getTenResourceList", "未获取到当前用户信息！");
				return result;
			}
			rolename=userInfo.getRoleName();
			userList.add(userInfo);
		} else {
			result.setCode(user.getCode());
			result.setMsg(user.getMsg());
			return result;
		}
		Calendar c = Calendar.getInstance();
		int mon = c.get(Calendar.MONTH) + 1;
		try {
			List<String> showColumns = DataCollectionFieldsEnum.getDefaultShowColumnEN();
			List<Map<String, Object>> data = null;

			// 获取数据采集列表
			data = dataCollectionService.getTenResourceListByConditionForPage(userInfo, isFinish,
					rootId, condition, page, showColumns, null,rolename);


			if (!CollectionUtils.isEmpty(data)) {
				Set<Integer> userIds = new HashSet<Integer>(data.size());
				for (Map<String, Object> m : data) {
					if (null != m) {
						if (m.containsKey("managerId") && null != m.get("managerId")) {
							userIds.add(Integer.parseInt(String.valueOf(m.get("managerId"))));
						}
						String frequency = String.valueOf(m.get("updateFrequency"));
						// 季度未完成的数据，非最后一个月改为进行中
						if ("Q".equals(frequency) && "0".equals(String.valueOf(m.get("isFinish")))) {
							if (mon % 3 > 0) {
								m.put("isFinish", "2");
							}
							// 年度未完成的数据，非最后一个月改为进行中
						} else if ("Y".equals(frequency) && "0".equals(String.valueOf(m.get("isFinish")))) {
							if (mon % 12 > 0) {
								m.put("isFinish", "2");
							}
						} else if (!"M".equals(frequency)) {
							m.put("isFinish", "3");
						}
					}
				}
				// 填充用户名称
				remoteBaseService.matchUserName(data, result, token, userIds, "managerId", "lastOperatorName");
			}
			result.setCount(page.getTotalCount());
			result.setData(data);
			return result;
		} catch (Exception e) {
			ExceptionLogger.error("BatchLogController#getTenResourceList", "获取数据采集资源异常！ERROR：" + e.getMessage(), e);
			result.setCode(RestServiceResult.CODE_UNKNOW);
			result.setMsg("获取数据采集资源异常！");
			return result;
		}
	}

}
